package org.jing.core.lang.data;

import org.jing.core.util.StringUtil;

/**
 * Description: 错误信息. <br>
 *
 * @author bks <br>
 * @since 2022-10-31 <br>
 */
@SuppressWarnings({ "WeakerAccess", "unused" })
public class ExceptionCause extends BaseDto {
    public static final String DEFAULT_ERR_CODE = "E999";

    public static final String DEFAULT_ERR_MSG = "Unknown Error";

    private String errorCode;

    private String errorMsg;

    /**
     * Description: 根据默认错误码和错误信息创建错误信息. <br>
     */
    public ExceptionCause() {
        this.setErrorCode(null);
        this.setErrorMsg(null);
    }

    /**
     * Description: 根据错误码和错误描述创建错误信息. <br>
     *
     * @param errorCode 错误码 <br>
     * @param errorMsg 错误描述 <br>
     */
    public ExceptionCause(String errorCode, String errorMsg) {
        this.setErrorCode(errorCode);
        this.setErrorMsg(errorMsg);
    }

    /**
     * Description: 获取错误码. <br>
     *
     * @return <br>
     */
    public String getErrorCode() {
        return errorCode;
    }

    /**
     * Description: 设置错误码. <br>
     *
     * @param errorCode 错误码 <br>
     */
    public void setErrorCode(String errorCode) {
        this.errorCode = StringUtil.ifEmpty(errorCode, DEFAULT_ERR_CODE);
    }

    /**
     * Description: 获取错误描述. <br>
     *
     * @return <br>
     */
    public String getErrorMsg() {
        return errorMsg;
    }

    /**
     * Description: 设置错误描述. <br>
     *
     * @param errorMsg 错误描述 <br>
     */
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = StringUtil.ifEmpty(errorMsg, DEFAULT_ERR_MSG);
    }
}
